
import requests
import re
import urllib
import ssl

URL = "http://v.hoopchina.com.cn/bbs-editor-web/179243461936539/1613922654227_245.mp4?auth_key=1614000701-0-0-31f969091df43417c22cd97b222cd6d2"
hd = {'User-Agent' : 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6'}

def main():
    context = ssl._create_unverified_context()

    request = urllib.request.Request(URL, headers=hd)
    res = urllib.request.urlopen(request, context = context)

    #匹配大盒子 视频URL

    url_MP4 = re.compile(r'(http://.*mp4{1})',re.S)  #正则匹配
    url_MP4s = re.findall(url_MP4, res.read().decode('utf8'))

    print(url_MP4s)
    for i in url_MP4s:
        urllib.request.urlretrieve(i,'haha.mp4')
    
    #print('下载成功')

if __name__ == '__main__':
    main()
